package org.springsocial.services.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springsocial.dao.TeamDao;
import org.springsocial.domain.Team;
import org.springsocial.services.TeamService;
import org.springsource.util.StringUtilityDashes;

@Service
public class TeamServiceImpl implements TeamService {

	@Autowired
	private TeamDao teamDao;
	
	@Override
	public Team getTeam(Long id) {
		return teamDao.getTeam(id);
	}

	@Override
	public List<Team> getAll() {
		return teamDao.getAll();
	}

	@Override
	public Team getTeamByName(String name) {
		return teamDao.getTeamByName(name);
	}

	@Override
	public List<Team> getTeamsByCountry(String countryCode) {
		return teamDao.getTeamsByCountry(countryCode);
	}
	
	@Transactional(propagation = Propagation.REQUIRED)
	@Override
	public Team saveTeam(Team team) {
		return teamDao.saveTeam(team);
	}

	@Override
	public List<Team> getTeamsByLevelName(String levelName) {
		return teamDao.getTeamsByLevelName(levelName);
	}

	@Override
	public Team getTeamWithPlayers(String name) {
		name = StringUtilityDashes.removeWhitespaces(name);
		return teamDao.getTeamWithPlayers(name);
	}

	@Override
	public Team getTeamTweets(String name) {
		return teamDao.getTeamTweets(name);
	}

	@Override
	public List<Team> getPremierLeagueTeams() {
		return teamDao.getPremierLeagueTeams();
	}

	@Override
	public List<Team> getPrimeraDivisionTeams() {
		return teamDao.getPrimeraDivisionTeams();
	}
	

}
